1. Field of the Invention
The present invention relates to an image compressing apparatus, an image compressing method and a program therefor, for compressing and coding image data according to JPEG2000 or such. The present invention in particular relates to compressing/decompressing static image or moving picture, and, in further particular, the present invention can be applied to image processing for a digital still camera, a recording part of a digital copier, a surveillance camera, a digital video storage, digital camera (for taking moving picture), a satellite communication apparatus, a medical equipment, a browser for the Internet, or such.
2. Description of the Related Art
Recently, as a compressing and coding method suitable to processing of high-definition images, JPEG2000 is known. In JPEG2000 coding, after given image data is transformed into respective color components of Y, Cb and Cr, two-dimensional discrete wavelet transform as frequency analysis is carried out on each of the respective data components.
JPEG2000 defines ways of compressing/decompressing image data.
FIG. 9 shows a functional block diagram for illustrating a basic JPEG2000 algorithm. This figure shows, in a block manner, an algorithm corresponding to various functions which actually a computer carries out according to a corresponding computer program for image processing, for JPEG2000 image compressing/decompressing.
As shown in FIG. 9, the JPEG2000 algorithm includes a color space transform/inverse transform part 111, a two-dimensional wavelet transform/inverse transform part 112, a quantization/inverse quantization part 113, an entropy coding/decoding part 114 and a tag processing part 115 (see Japanese Laid-Open Patent Application 2004-214828 (Patent Document 1), corresponding to United States Patent Publication No. US 2006/0228028 A1).
Wavelet transform coefficient data (for example, 16-bit data) obtained from the wavelet transform is divided into bit planes in which sub-bands (for example, in a case of three-level wavelet transform, 3LL, 3HL, 3LH, 3HH, 2HL, 2LH, 2HH, 1HL, 1LH and 1HH) are used as processing units. Then, for each sub-band, the respective bit planes are scanned in sequence in three types of methods, and arithmetic coding is carried out. The above-mentioned three types of methods are called “significant propagation pass”, “magnitude refinement pass” and “cleanup pass”.
Compressing of the code data is carried out in such a manner that the code data of the coding passes of all the code blocks of the respective sub-bands obtained from the above-mentioned scanning in the three types of methods is partially deleted (truncated) uniformly in sequence from the least significant bit planes. There, deleting of the code data means that a value of the bit data to be deleted is replaced by 0 (null data). Details of JPEG2000 coding are known, for example, see ‘General outline of new international standard method of static image coding (JPEG2000)’, Institute of Image Information and Television Engineer, year 2000, Vol. 54, No. 2, pages 164-171 (Non-patent document).
Further, other than the above-mentioned Japanese Laid-Open Patent Application 2004-214828 (Patent Document 1), Japanese. Laid-Open Patent Application No. 2004-304238 (Patent document 2) and Japanese Laid-Open Patent Application 2004-297712 (Patent document 3), disclose image compressing technologies, for example.
According to Japanese Laid-Open Patent Application 2004-214828 (Patent Document 1), means for executing image compressing according to JPEG2000 and means for decompressing images compressed according to a method other than JPEG2000 standard, are provided. Designation of a region of interest is allowed for an image file stored in a storage area. It is determined whether the image file is a non-compressed file or a compressed file compressed according to the method other than JPEG2000 standard, When it is determined that the image filed is the non-compressed image file, it is compressed by the compressing means. When it is determined that the image file is the compressed file compressed according to the method other than JPEG2000 standard, it is once decompressed by the decompressing means, and then, it is compressed by the compressing means. Then, from the thus-compressed image, a block corresponding to the designated region of interest is extracted and output.
According to Japanese Laid-Open Patent Application No. 2004-304238 (Patent document 2), corresponding to United States Patent Publication No. US 2006/0177138 A1, a coding part for generating code data by coding coefficient data obtained from frequency analysis of image data for each processing unit; a data reducing part reducing the code data amount by deleting the code data thus generated for each processing unit by the coding part; and a data processing part dividing the coefficient data in the respective processing units into coefficient data in second processing units, and, increasing the code data reducing amount in the data reducing part according to a value size of the coefficient data in the second processing units, are provided.
According to Japanese Laid-Open Patent Application 2004-297712 (Patent document 3), corresponding to United States Patent Publication, No. 2004/0161156 A1, a coding part generating code data by coding given coefficient data obtained from frequency analysis carried out on given image data; a table in which data determining contents to delete the code data from the code data corresponding to the least significant bits of the coefficient data in the respective processing units are arranged in such a manner that the code data deleting amount gradually increases or decreases along with increase in the data numbers, and also, reproduction image quality gradually degrades or improves; and a rate control part calculating a variable of the code data obtained when the code data is deleted according to the data read from the table and determining the data number of data in which the variable of the calculated code data can be regarded as a target value.
FIG. 10 shows a configuration of an image compressing apparatus according to the above-mentioned Patent documents 2 and 3.
As shown in FIG. 10, the image compressing apparatus 100 includes a wavelet transform part 10, an arithmetic coding part 20, a packet header generating part 30, a memory controller 40 and a DRAM 50. The memory controller 40 acts as a so-called arbiter circuit, and carries out arbitration of a data access right to the DRAM 50 from DMAs 13, 21, 25, 31, 33, 35 and 37 included in the above-mentioned wavelet transform part 10, the arithmetic coding part 20 and the packet header generating part 30.
The wavelet transform part 10 transforms given image data into 16-bit wavelet coefficients. A color transform circuit 11 transforms given image data into respective color components of Y, Cb and Cr, and outputs the same. A wavelet transform circuit 12 carries out two-dimensional discrete wavelet transform on data of the respective color components obtained from the color transform. The DMA 13 stores, in a predetermined address of the DRAM 50, the thus-generated wavelet coefficients.
The arithmetic coding part 20 carries out arithmetic coding of the wavelet coefficients thus stored in the DRAM 50, writes code data in the DRAM 50 for respective coding passes of each sub-band, also, determines a mask amount (number of coding passes) for each code block of each sub-band, and writes the thus-determined mask amount in a memory A or B.
Further, from the thus-obtained mask amounts and code amounts for the respective coding passes of each code block, a code amount to reduce when the coding passes of each sub-band are deleted one by one based on truncation data is determined, and the thus-obtained value is written in a memory C or D.
The DMA 21 reads, in sub-band units, the wavelet coefficients from the DRAM 50. The thus-read 16-bit wavelet coefficients are entropy-coded, then, are input to a bit-plane dividing circuit and, are divided into 16 bit planes.
An arithmetic coding circuit 24 carries out arithmetic coding with scanning the data of the respective bit planes for each sub-band in sequence from the most significant bits in the above-mentioned three types of methods (called the coding passes). The above-mentioned three types of methods are called ‘significant propagation pass’, ‘magnitude refinement pass’ and ‘cleanup pass’, as mentioned above. The code data output from the arithmetic coding circuit 24 is configured by code data of 46 coding passes (i.e., 15×3+1=46), and, is written in the DRAM 50 by means of the DMA 25.
The wavelet coefficients read from the DRAM 50 by the DMA 21 are input, not only in the quantization circuit 22 but also in an average calculating circuit 26. The average calculating circuit 26 calculates an average of the wavelet coefficients of effective pixels of each code block, and outputs the same.
A masking coefficient calculating circuit 27 determines an additional masking coefficient of ‘zero’, ‘one’ or ‘two’ coding passes, i.e., a mask amount (the number of coding passes to delete the code data) according to the average of the wavelet coefficients of each code block, output from the average calculating circuit 26 in sequence.
The memories A and B act as memories alternately switched in frame image units to process, and record the mask amount of each sub-band, output from the masking coefficient circuit 27.
The code data output from the arithmetic coding circuit 24 is output also to a code amount calculating circuit 28. The code amount calculating circuit 28 counts the code amount for each coding pass corresponding to the bit plane of each code block, and outputs the thus-obtained coefficient value to a data processing circuit 29.
To the data processing circuit 29, further the mask amounts (each corresponding to the number of coding passes) of the respective code blocks written in the memories A and B are output. The data processing circuit 29 further obtains a code data reducing amount determined in consideration of the mask amount, for when the coding passes of the code data of each sub-band are reduced one by one from the least significant bit plane, and, writes data representing the thus-obtained code data reducing amounts in the memories C and B.
The packet header generating part 30 determines a data number of truncation data appropriate to reduce a predetermined amount of the code data, based on the code data reducing amount, for when the coding passes of the code data of each sub-band obtained in the above-mentioned arithmetic coding part 20 is reduced one by one from the least significant bit plane, also with the mask amount for each code block being considered, then generates a packet header of the code data obtained based on the truncation data of the thus-determined data number, creates a bit stream, and outputs the same.
First, a rate control circuit 32 reads, from the DRAM 50 by means of the DMA 31, the truncation data of the data number 128, calculates a total of code data reducing amounts determined for the respective code blocks for all the sub-bands, according to the thus-read truncation data, and compares it with a target reducing amount.
When the target reducing amount has not yet reached, then the truncation data of the larger data number is read, and, according to the thus-read truncation data, the total of the code data reducing amounts are obtained for all the sub-bands. On the contrary, i.e., when the target reducing amount has been already exceeded, then the truncation data of the smaller data number is read, and, according to the thus-read truncation data, the total of the code data reducing amounts are obtained for all the sub-bands, again. Thus, the single data number of the truncation data, with which the above-mentioned total code data reducing amount can be regarded as the target reducing amount, is determined, and data representing the thus-obtained data number is output to a subsequent packet information generating circuit 34.
The rate control part 32 generally includes an address generating circuit, a code amount calculating circuit and a data number switching circuit. The address generating circuit and the code amount calculating circuit function as a calculating part for reading the truncation data of the designated data number from the above-mentioned truncation table, and calculating the code amount variable for when the code data on the side of the least significant bit from the code data in respective processing units is deleted according to the thus-read truncation data. The address generating circuit generates an address for reading data of the code amount of the bit plane to add or reduce based on the truncation data input by means of the DMA 31, and outputs the same in the memories C and D.
One of the memories C and D in an enable state storing the data of frame images which are currently processed, outputs, from the designated address, the stored code data to the code amount calculating circuit.
The code amount calculating circuit thus obtains the total of the code data reducing amounts for all the sub-bands, thus sent from the memory C or D, compares the thus-obtained total amount with the target reducing amount, and outputs a signal indicating the comparison result to the subsequent data number switching circuit.
The data number switching circuit requests, from the DRAM 50, the different data number of truncation data, based on the comparison result signal thus-output from the code amount calculating circuit for some case. Or, the data number switching circuit outputs a signal indicating that the final data number with which the code data reducing amount can be regarded as the target reducing amount, to the packet information generating circuit 34.
A packet header generating circuit 36 generates a packet header from data of the above-mentioned calculated numbers of the coding passes and the code amounts of the code blocks of the respective sub-bands and the number of zero bit planes output from the packet information generating circuit 34, as well as data of the code data read from the DRAM 50 by means of the DMA 37, and so forth, and outputs the same to a code creation circuit 38.
The code creation circuit 38 creates a bit stream from the data output from the packet header generating circuit 36, and thus, outputs the code data from which the code data has been thus reduced by the target reducing amount. Thus, the general outline of the image compressing apparatus according to the above-mentioned Patent documents 2 and 3 has been discussed.
According to JPEG2000, a function called ROI (Region Of Interest) is provided for improving an image quality only for a ‘part selected from a given image’. In order to achieve the ROI function, it is necessary to carry out predetermined processing corresponding thereto previously upon coding the same. According to a basic way of JPEG2000, a method of ‘weighting coefficients of a region of interest’ is used. Specifically, exponentiation of 2 is used for the weighting, by means of a bit shift.
FIG. 11 shows a processing flow of JPEG2000 coding in the related art.
As shown in FIG. 11, a given image is wavelet-transformed (Step S501), is quantized (Step S502) and is MQ (arithmetic)-coded (Step S503), code is thus created (Step S504), and thus, compressed image data is obtained (Step S504). Commonly, in order to achieve the ROI function, the corresponding processing should be carried out previously upon coding.
FIG. 12 shows a flow including the above-mentioned ROI processing carried out upon coding.
As shown in FIG. 12, a given image is wavelet-transformed (Step S601), is bit-shifted (Step S602), is quantized (Step S603) and is MQ (arithmetic)-coded (Step S604), code is thus created (Step S605), and thus, compressed image data is obtained (Step S606).
As a specific method to be used for the ROI processing, two methods may be used. That is, according to the first method, in the quantizing Step, quantization is made more finely for the ROI, with respect to the other region. According to the second method, weighting is made on the ROI. In the second method, specifically, as mentioned above, exponentiation of 2 is used for the weighting, by means of a bit shift (corresponding to Step S602 of FIG. 12).
The basic way of JPEG2000 adopts the second method. An actual amount of the bit shift corresponds to the maximum number of bits of coefficients of the region other than the ROI. From this point, this method is called ‘Maxshift method’. The coefficients of the ROI region should be returned to the same range as that of the coefficients of the other region (background region) upon decoding, while the shifted-up state obtained from the bit shift should be maintained.
FIG. 13 shows a flow of the ROI processing upon decoding. Basically, the processing is carried out in the order reverse to that of the processing shown in FIG. 12. That is, compressed data is code-analyzed (Step S701), is MQ-decoded (Step S702), is inverse-quantized (Step S702), is bit-shifted (Step S703), and then, is inverse-wavelet-transformed (Step S704), and thus, an image is restored (Step S706).
Thus, in the bit shift method, ROI mask information should be created upon coding and upon decoding, and also, a circuit for carrying out a bit shift of wavelet coefficients and a circuit for calculating a bit-shift amount should be provided. Further, for a case of processing an image such as a color image which has a plurality of components, sub-sampling processing may be required in many cases. When sub-sampling is carried out, the ROI mask should be sub-sampled accordingly.
Thus, in the related art, in order to achieve a function analogous to the ROI function by adjusting a code amount in such a manner that a target code amount may be reached, and improving image quality of the ROI, a bit shift should be carried out for weighting coefficients and the shift amount should be calculated. Thus, a circuit configuration may become complicated.